<template>
  <div class="app-container">
    <div class="filter-container">
      <span class="filter-title filter-item">饰品品质</span>
      <k-select
        v-model="listQuery.rarityId"
        class="filter-item babyquality"
        type="1"
        :select-params="dict.type.ORNAMENT_QUALITY"
        @handleSelectEvent="handleFilter"
      />
      <span class="filter-title filter-item">饰品外观</span>
      <k-select
        v-model="listQuery.exteriorId"
        class="filter-item babylook"
        type="1"
        :select-params="dict.type.ORNAMENT_APPEARANCE"
        @handleSelectEvent="handleFilter"
      />

      <span class="filter-title filter-item">饰品类别</span>
      <k-select
        v-model="listQuery.qualityId"
        class="filter-item babytype"
        :select-params="dict.type.ORNAMENT_CATEGORY"
        @handleSelectEvent="handleFilter"
      />
      <span class="filter-title filter-item">饰品分类</span>
      <k-select
        v-model="listQuery.typesId"
        class="filter-item babycategory"
        :custom-params="{opations:categoryList, label:'lineName',value:'lineId'}"
        @handleSelectEvent="handleCategoryFilter"
      />
      <k-select
        v-model="listQuery.typeId"
        class="filter-item babycategory"
        :custom-params="{opations:categorySecondTypeList, label:'lineName',value:'lineId'}"
        @handleSelectEvent="handleFilter"
      />
      <k-input
        v-model.trim="listQuery.key"
        class="filter-item"
        is-search
        placeholder="饰品名称或关键词"
        :search-fun="handleFilter"
        @keyup.enter.native="handleFilter"
      />
    </div>
    <div class="top-right-btn-container">
      <k-button v-if="authorityHandle(37)" class="top-btn" value="添加饰品" @click.native="addBabyDialog" />
      <k-button v-if="authorityHandle(37)" class="top-btn" value="删除饰品" @click.native="deleteBabyDialog" />
      <k-button class="top-btn" value="算法/概率设置" @click.native="mathSettingDialog" />
      <k-button class="top-btn" value="赠送饰品配置" @click.native="giveBabySettingDialog" />
      <k-button class="top-btn" value="晶粹配置" @click.native="bulletSettingDialog" />
      <!-- <k-button class="top-btn" value="玩法介绍" @click.native="ruleGuideDialog" /> -->
      <k-button class="top-right-btn" value="设置" @click.native="settingDialog" />
    </div>
    <!--表格相关 -->
    <el-table
      :data="babylist"
      fit
      highlight-current-row
      style="width: 100%;border-radius:8px;"
      :header-cell-style="{background:'#F6F5FA',color:'#4E4F62'}"
      @selection-change="handleSelectionChange"
      @sort-change="sortChange"
    >
      <el-table-column v-if="authorityHandle(37)" min-width="60px" type="selection" align="center" />
      <el-table-column width="60px" label="序号" align="center">
        <template slot-scope="scope">
          <div>
            <svg-icon v-show="babylist[scope.$index].warningMsg" icon-class="warning" />
            {{ scope.$index + 1 }}
          </div>
        </template>
      </el-table-column>
      <el-table-column min-width="150px" label="图标" align="center">
        <template slot-scope="scope">
          <el-image
            style="width: 110px; height: 80px"
            :src="scope.row.iconUrl"
            :preview-src-list="[scope.row.iconUrl]"
            fit="contain"
          />
        </template>
      </el-table-column>
      <el-table-column prop="goodsCnName" min-width="120px" label="饰品名称" show-overflow-tooltip align="center" />
      <el-table-column label="扎比特数据" align="center">
        <el-table-column prop="zbtMinPrice" label="最低价" min-width="80" sortable="custom" align="center" />
        <el-table-column prop="zbtSellNum" label="当前数量" min-width="80" sortable="custom" align="center" />
      </el-table-column>
      <el-table-column prop="zbtOfficialPrice" min-width="80px" label="参考价" sortable="custom" show-overflow-tooltip align="center" />

      <el-table-column v-if="authorityHandle(37)" prop="customPrice" min-width="120px" label="自定义价格" sortable="custom" align="center">
        <template slot-scope="scope">
          <div @click="{{changeNum(scope.$index)}}">
            <el-input v-if="editable[scope.$index]" v-model="scope.row.customPrice" v-focus @keyup.enter.native="upcustomPrice(scope)" @blur="blurInput(scope.$index)" />
            <span v-else :style="{'color':scope.row.isUpdate === 2 ? '#3b425d':'#409EFF'}">{{ scope.row.customPrice }}</span>
          </div>
        </template>
      </el-table-column>

      <el-table-column v-else prop="customPrice" min-width="120px" label="自定义价格" sortable="custom" align="center" />

      <el-table-column prop="rarityName" min-width="100px" label="品质" show-overflow-tooltip align="center" />
      <el-table-column prop="exteriorName" min-width="100px" label="外观" show-overflow-tooltip align="center" />
      <el-table-column prop="categoryName" min-width="100px" label="分类" show-overflow-tooltip align="center" />
      <el-table-column prop="qualityName" min-width="100px" label="类别" show-overflow-tooltip align="center" />
      <el-table-column min-width="300px" label="饰品状态" align="center">
        <template slot-scope="scope">
          <div class="op-div">
            <el-switch
              v-model="scope.row.upStatus"
              style="display: block; margin-right:20px"
              active-color="#3b425d"
              inactive-color="#E9EBF2"
              active-text="上架"
              inactive-text="下架"
              :active-value="1"
              :inactive-value="2"
              :disabled="!authorityHandle(37)"
              @change="boxOnlineState(scope)"
            />
            <el-switch
              v-model="scope.row.hotStatus"
              style="display: block"
              active-color="#3b425d"
              inactive-color="#E9EBF2"
              active-text="热推"
              inactive-text="正常"
              :active-value="1"
              :inactive-value="2"
              :disabled="!authorityHandle(37)"
              @change="boxHostState(scope)"
            />
          </div>
        </template>
      </el-table-column>
      <el-table-column min-width="120px" label="操作" align="center">
        <template slot-scope="scope">
          <k-button class="table-btn" value="查看/修改" @click.native="updateBabyDialog(scope.row)" />
        </template>
      </el-table-column>
    </el-table>
    <pagination
      v-show="totalRows > 0"
      :total="totalRows"
      :page.sync="listQuery.pager.pageNo"
      :limit.sync="listQuery.pager.pageSize"
      @pagination="loadData"
    />
    <!-- 算法/概率设置 弹窗 -->
    <k-dialog
      :show-hide.sync="mathSetting.showHide"
      :modal-append-to-body="false"
      :append-to-body="true"
      class="giveBaby-dialog"
      title="算法/概率设置"
      :show-foot="false"
      :two-btn="authorityHandle(37)"
      @click="saveWarningNum"
    >
      <el-radio-group v-model="babyType" fill="#3b425d" text-color="#ffffff" class="top-radio-group">
        <el-radio-button label="probability">概率设置</el-radio-button>
        <el-radio-button label="algorithm">算法设置</el-radio-button>
      </el-radio-group>
      <div class="dialog-giveBabySetting">
        <div v-if="babyType === 'probability'" style="padding:20px;margin-left:50px">
          <el-form :model="mathSettingModle" label-width="auto">
            <el-form-item label="饰品最低概率：" prop="phonenumber">
              <el-input v-model="mathSettingModle.minProbability" :readonly="!authorityHandle(37)" placeholder="请输入概率" />
            </el-form-item>
            <el-form-item label="饰品最高概率：" prop="phonenumber">
              <el-input v-model="mathSettingModle.maxProbability" :readonly="!authorityHandle(37)" placeholder="请输入概率" />
            </el-form-item>
            <!-- <el-form-item label="玩家概率差值百分比：" prop="phonenumber">
              <el-input v-model="mathSettingModle.userPercent" placeholder="请输入百分比" />
            </el-form-item> -->
            <el-form-item label="主播概率差值百分比：" prop="phonenumber">
              <el-input v-model="mathSettingModle.fissionPercent" :readonly="!authorityHandle(37)" placeholder="请输入百分比" />
            </el-form-item>
          </el-form>
        </div>
        <div v-if="babyType === 'algorithm'" style="padding:50px;margin-bottom:100px">
          拉货价格 = ( 饰品价格 * 饰品爆率 ) * (1 +
          <el-input v-model="mathSettingModle.pricePercent" :readonly="!authorityHandle(37)" class="price-input" placeholder="请输入数值" />
          )
        </div>
      </div>

    </k-dialog>
    <!-- 添加饰品 弹窗 -->
    <k-dialog
      :show-hide.sync="addBaby.showHide"
      :modal-append-to-body="false"
      :append-to-body="true"
      :title="textMap[dialogStatus]"
      class="addBaby-dialog"
      :two-btn="authorityHandle(37)"
      :close-fun="handleCloseDialog"
      @click="addGoodsToLuck"
    >
      <el-form label-width="auto">
        <el-form-item label="添加饰品：">
          <el-select
            v-model="addGoodModel.id"
            filterable
            placeholder="请选择"
            :disabled="!authorityHandle(37)"
            @change="selectChange"
          >
            <el-option
              v-for="item in goodsResultList"
              :key="item.lineId"
              :label="item.lineName"
              :value="item.lineId"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="饰品父级分类：">
          {{ typeName }}
        </el-form-item>
        <el-form-item label="饰品子级分类：">
          <el-select v-model="addGoodModel.type":disabled="!authorityHandle(37)" clearable placeholder="请选择">
            <el-option
              v-for="item in typeList"
              :key="item.id"
              :label="item.typeName"
              :value="item.id"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="拉货价格百分比：" prop="phonenumber">
          <el-input v-model.number="addGoodModel.probabilityThreshold" :readonly="!authorityHandle(37)" placeholder="请输入数值" />
        </el-form-item>   <el-form-item label="满格出货概率：" prop="phonenumber">
          <el-input v-model.number="addGoodModel.probabilityReal" :readonly="!authorityHandle(37)" placeholder="请输入数值" />
        </el-form-item>
      </el-form>
    </k-dialog>
    <!-- 玩法介绍 弹窗 -->
    <k-dialog
      :show-hide.sync="ruleGuide.showHide"
      :modal-append-to-body="false"
      :append-to-body="true"
      title="玩法介绍"
      class-name="ruleGuide-dialog"
      :show-foot="false"
      :two-btn="authorityHandle(37)"
      @click="guideSave"
    >
      <div class="dialog-ruleGuide" style="padding:30px">
        <el-form :model="ruleGuideContent" label-width="auto">
          <el-form-item label="内容介绍：" prop="content">
            <quill-editor
              ref="myQuillEditor"
              v-model.trim="ruleGuideContent.content"
              :options="editorOption"
              class="editer"
            />
          </el-form-item>
        </el-form>
      </div>
    </k-dialog>
    <!-- 赠送饰品配置 弹窗 -->
    <k-dialog
      :show-hide.sync="giveBabySetting.showHide"
      :modal-append-to-body="false"
      :append-to-body="true"
      title="赠送饰品配置"
      class="addBox-dialog"
      :two-btn="authorityHandle(37)"
      :close-fun="giveBabyCloseDialog"
      @click="saveGiveBabyData"
    >
      <el-form label-width="auto" class="give_div">
        <el-form-item label="饰品名称：">
          <el-select
            v-model="goodsValueModel"
            multiple
            style="width: 100%;"
            filterable
            placeholder="请选择"
            :disabled="!authorityHandle(37)"
            @change="selectGiveBabyChange"
          >
            <el-option
              v-for="item in giveGoodsResultList"
              :key="item.lineId"
              :label="item.lineName"
              :value="item.lineId"
            />
          </el-select>
        </el-form-item>
      </el-form>
    </k-dialog>
    <!-- 设置 弹窗 -->
    <k-dialog
      :show-hide.sync="setting.showHide"
      :modal-append-to-body="false"
      :append-to-body="true"
      title="设置"
      :two-btn="authorityHandle(37)"
      @click="closeSettingDialog"
    >
      <div class="setting-contanier">
        <el-form label-width="auto">
          <el-form-item label="父级分类：">
            <el-tag
              v-for="(good, index) in categoryList"
              :key="good.lineId"
              :class="{activity:activityindex == index}"
              @click="tagclick(good, index)"
            >
              {{ good.lineName }}
            </el-tag>
          </el-form-item>
          <el-form-item label="子级分类：">
            <div class="box-container">
              <el-tag
                v-for="good in categorySecondTypeList"
                :key="good.lineId"
                :closable="authorityHandle(37)"
                :disable-transitions="false"
                @close="handleGoodsTagDelete(good)"
              >
                {{ good.lineName }}
              </el-tag>
              <el-input
                v-if="inputVisible"
                ref="saveTagInput"
                v-model="inputValue"
                class="input-new-tag"
                size="small"
                @blur="handleInputBlur"
                @keyup.enter.native="handleInputConfirm"
              />
              <el-button v-else v-if="authorityHandle(37)" class="button-new-tag" size="small" @click="addNewItemGood">
                + 添加分类
              </el-button>
            </div>
          </el-form-item>
        </el-form>
      </div>
    </k-dialog>
    <!-- 晶粹配置 弹窗 -->
    <k-dialog
      :show-hide.sync="bulletSetting"
      :modal-append-to-body="false"
      :append-to-body="true"
      title="晶粹配置"
      class-name="creatRollRoom_dialog"
      :show-foot="false"
      :two-btn="authorityHandle(37)"
      @click="saveBulletSetting"
    >
      <div class="set_box">
        <div v-for="(item, index) in bulletSettingItemList" :key="item.id" class="Recharge_Data">
          <div class="Recharge_Data_box">
            <span>拉货价值区间{{ index + 1 }}:</span>
            <el-input v-model.trim="item.minAmount" :readonly="!authorityHandle(37)" />
            <i style="margin: 0 2px;"> — </i>
            <el-input v-model.trim="item.maxAmount" :readonly="!authorityHandle(37)" />
          </div>
          <div class="operation">
            <i v-if="authorityHandle(37)" v-show="index != 0" class="el-icon-remove" @click="deleteItem(item.id,index)" />
            <i v-if="authorityHandle(37)" v-show="index == bulletSettingItemList.length - 1" class="el-icon-circle-plus" @click="newlyAdded()" />
          </div>
        </div>
      </div>
    </k-dialog>
  </div>
</template>

<script>
import { getGoodsPlatformList, getGoodsLuckyPlatformList, getFirstTypeList, getSecondTypeListById, saveType, deleteType, getLuckyDescribe, setLuckyDescribe, lucklistData, getTypeByGoodsId, addGoodsToLuck, deleteGoodsFromLucky, updateGoods, updateUpStatus, updateHotStatus, getLuckyProbabilityVO, setLuckyProbabilityVO, setOtherGoodsList, getOtherGoodsList } from '@/api/rules/listdata'
import { updateGoodsPrice } from '@/api/babylib/platformlib/listdata'
import { setAmmoLuckyGradeList, getAmmoLuckyGradeList } from '@/api/bullet/index'
import Pagination from '@/components/Pagination' // secondary package based on el-pagination

export default {
  components: { Pagination },
  directives: {
    focus: {
      inserted: function(el) {
        el.querySelector('input').focus()
      }
    }
  },
  dicts: ['ORNAMENT_QUALITY', 'ORNAMENT_APPEARANCE', 'ORNAMENT_CATEGORY'],
  data() {
    return {
      bulletSettingItemList: [{
        id: undefined,
        minAmount: undefined,
        maxAmount: undefined,
        sort: undefined
      }],
      dialogStatus: 'create',
      textMap: {
        update: '修改/查看详情',
        create: '添加饰品'
      },
      activityindex: 0,
      addGoodModel: {
        id: undefined,
        type: undefined,
        probabilityThreshold: undefined,
        probabilityReal: undefined
      },
      goodsResultList: [],
      goodsValueModel: [],
      giveGoodsResultList: [],
      checkedGiveBabyList: [],
      currParentId: undefined,
      typeName: '',
      goodNameLook: '', // 查看修改显示的时候
      typeList: [],
      mathSettingModle: {
        pricePercent: undefined, // 价格差",
        minProbability: undefined, // 饰品最低概率",
        maxProbability: undefined, // 饰品最高概率",
        userPercent: undefined, // 玩家概率差值百分比",
        fissionPercent: undefined // 主播概率差值百分比"
      },
      ruleGuideContent: {
        content: ''
      },
      editorOption: { //  富文本编辑器配置
        placeholder: '请输入内容',
        modules: {
          toolbar: [
            ['bold', 'italic', 'underline', 'strike'], // 加粗，斜体，下划线，删除线
            ['blockquote', 'code-block'], // 引用，代码块
            [{ 'header': 1 }, { 'header': 2 }], // 标题，键值对的形式；1、2表示字体大小
            [{ 'list': 'ordered' }, { 'list': 'bullet' }], // 列表
            [{ 'script': 'sub' }, { 'script': 'super' }], // 上下标
            [{ 'indent': '-1' }, { 'indent': '+1' }], // 缩进
            [{ 'direction': 'rtl' }], // 文本方向
            [{ 'size': ['small', false, 'large', 'huge'] }], // 字体大小
            [{ 'header': [1, 2, 3, 4, 5, 6, false] }], // 几级标题
            [{ 'color': [] }, { 'background': [] }], // 字体颜色，字体背景颜色
            [{ 'font': [] }], // 字体
            [{ 'align': [] }], // 对齐方式
            ['clean'], // 清除字体样式
            ['image'] // 上传图片、上传视频
          ]
        }
      },
      editable: [],
      categoryList: [],
      categorySecondTypeList: [],
      totalRows: 0, // 分页组件--数据总条数
      babylist: [], // 表格的数据
      listQuery: {
        pager: {
          pageNo: 1,
          pageSize: 10,
          totalRows: '',
          start: ''
        },
        sort: '', // 排序字段 为对应列名,
        direction: '', // 排序 正向(asc)逆向(desc),
        categoryId: undefined, // 饰品分类,
        exteriorId: undefined, // 饰品外观',
        qualityId: undefined, // 饰品类别',
        rarityId: undefined, // 饰品品质',
        key: '', // 饰品名称'
        typesId: undefined, // 饰品父分类",
        typeId: undefined // 饰品子分类"
      },
      giveBabySettingModel: {
        warningStockArray: [{
          id: -1,
          num: undefined,
          minPrice: '',
          maxPrice: ''
        }],
        warningPriceArray: [{
          id: -1,
          minPrice: '',
          maxPrice: '',
          lowPercent: '',
          upPercent: ''
        }]
      },
      inputVisible: false,
      inputValue: '',
      babyType: 'probability',
      probility: {
        prob: ''
      },
      giveBabySetting: {
        showHide: false
      },
      mathSetting: {
        showHide: false
      },
      addBaby: {
        showHide: false
      },
      ruleGuide: {
        showHide: false
      },
      setting: {
        showHide: false
      },
      bulletSetting: false,
      multipleSelection: []
    }
  },
  created() {
    this.loadData()
    this.getCategory()
    this.getGoodsPlatformList()
    this.getGeneralDescribe()
  },
  methods: {
    loadData() {
      lucklistData(this.listQuery).then(res => {
        const data = res.data
        this.$log(data)
        this.babylist = data.rows
        this.totalRows = data.totalRows
      })
    },
    // 晶粹配置
    bulletSettingDialog() {
      getAmmoLuckyGradeList().then(res => {
        this.bulletSettingItemList = res.data
      })
      this.bulletSetting = true
    },
    // 晶粹配置
    saveBulletSetting() {
      this.bulletSettingItemList.map((item, index) => {
        item.sort = index
      })
      setAmmoLuckyGradeList(this.bulletSettingItemList).then(res => {
        this.$message.success('保存成功')
      })
      this.bulletSetting = false
      this.$router.push({ path: '/rootplayrules/bullet-setting' })
    },
    // 设置新增
    newlyAdded() {
      this.bulletSettingItemList.push({
        id: undefined,
        minAmount: undefined,
        maxAmount: undefined,
        probability: undefined
      })
    },
    // 设置删除
    deleteItem(value, indexItem) {
      if (!value) {
        this.bulletSettingItemList.splice(indexItem, 1)
        return
      }
      var index = this.bulletSettingItemList.findIndex(function(item) {
        return item.id === value
      })
      if (index !== -1) {
        this.bulletSettingItemList.splice(index, 1)
      }
    },
    // 箱子热推
    boxHostState(scope) {
      const id = scope.row.id
      updateHotStatus({ 'id': id }).then(res => {
        this.$log(res)
      })
    },
    // 箱子上架
    boxOnlineState(scope) {
      const id = scope.row.id
      updateUpStatus({ 'id': id }).then(res => {
        this.$log(res)
      })
    },

    // 添加饰品
    // 请求饰品
    getGoodsLuckyPlatformList() {
      getGoodsLuckyPlatformList().then(res => {
        this.goodsResultList = []
        Object.assign(this.goodsResultList, res.data)
      })
    },

    // 添加饰品
    // 请求饰品
    getGoodsPlatformList() {
      getGoodsPlatformList({ 'key': '', 'alreadyIds': '[-1]' }).then(res => {
        this.giveGoodsResultList = []
        Object.assign(this.giveGoodsResultList, res.data)
      })
    },

    // 设置 父级分类点击
    tagclick(good, index) {
      this.currParentId = good.lineId
      this.currTypeName = good.lineName
      this.activityindex = index
      this.getSecondTypeListById(this.currParentId)
    },
    // 添加新的饰品
    addNewItemGood() {
      this.inputVisible = true
      this.$nextTick((_) => {
        this.$refs.saveTagInput.$refs.input.focus()
      })
    },
    handleInputBlur() {
      this.inputVisible = false
      this.inputValue = ''
    },
    //  确定添加新的专区保存专区
    handleInputConfirm() {
      const inputValue = this.inputValue
      this.inputVisible = false
      this.inputValue = ''
      if (!inputValue) return
      const parentId = this.currParentId
      if (parentId === undefined) {
        return
      }
      saveType({ parentId: parentId, typeName: inputValue }).then(res => {
        if (res.data.success) {
          const id = res.data.data
          const addBabyInfo = {}
          addBabyInfo.lineId = id
          addBabyInfo.lineName = inputValue
          this.categorySecondTypeList.push(addBabyInfo)
        } else {
          this.$message.error(res.data.msg)
        }
      })
    },
    // 删除饰品
    handleGoodsTagDelete(tag) {
      this.$log(tag.lineId)
      if (!tag.lineId) {
        this.$message.success('删除失败')
        return
      }
      deleteType({ 'id': tag.lineId }).then(res => {
        if (res.data.success) {
          this.categorySecondTypeList.splice(this.categorySecondTypeList.indexOf(tag), 1)
          this.$message.success('删除成功')
        } else {
          this.$message.warning(res.data.msg)
        }
      })
    },
    // 自定义价格
    upcustomPrice(scope) {
      const index = scope.$index
      this.blurInput(index)
      const price = scope.row.customPrice
      const id = scope.row.id
      updateGoodsPrice({ id: id, customPrice: price }).then(res => {
        this.$log('价格修改成功')
        scope.row.isUpdate = 2
      })
    },
    blurInput(index) {
      this.editable[index] = false
      this.$set(this.editable, index, false)
    },
    changeNum(index) {
      this.editable[index] = true
      this.$set(this.editable, index, true)
    },
    // 添加饰品 房里边的饰品选择事件
    selectChange(value) {
      getTypeByGoodsId({ 'id': value }).then(res => {
        this.typeList = res.data.typeList
        this.typeName = res.data.typeName
        this.$log(this.typeList)
      })
    },
    // 添加饰品
    addGoodsToLuck() {
      if (this.addGoodModel.id === undefined || this.addGoodModel.type === undefined) {
        this.$message.error('数据出错')
        return
      }
      if (this.dialogStatus === 'create') {
        addGoodsToLuck(this.addGoodModel).then(res => {
          this.$message.success('保存成功')
          this.addBaby.showHide = false
          this.handleFilter()
        })
      } else {
        updateGoods(this.addGoodModel).then(res => {
          this.$message.success('修改成功')
          this.handleFilter()
        })
      }
      this.addBaby.showHide = false
    },
    // 获取饰品分类
    getCategory() {
      getFirstTypeList().then(res => {
        const data = res.data
        if (data.length <= 0) return
        this.categoryList = data
        this.currParentId = data[0].lineId
      })
    },
    closeSettingDialog() {
      this.setting.showHide = false
    },
    // 由id获取2级分类
    getSecondTypeListById(id) {
      getSecondTypeListById({ id: id }).then(res => {
        this.categorySecondTypeList = []
        const data = res.data
        this.categorySecondTypeList = data
        this.$log(this.categorySecondTypeList)
      })
    },
    handleCategoryFilter(value) {
      this.handleFilter()
      this.getSecondTypeListById(value)
    },
    // 搜索查询事件
    handleFilter() {
      this.listQuery.pager.pageNo = 1
      this.loadData()
    },
    // 选择项发生变化时会触发该事件
    handleSelectionChange(val) {
      this.multipleSelection = val
    },
    // 表格的排序条件发生变化的时候会触发该事件
    sortChange(column, prop, order) {
      this.listQuery.sort = column.prop
      if (column.order === 'ascending') {
        this.listQuery.direction = 'asc'
      } else if (column.order === 'descending') {
        this.listQuery.direction = 'desc'
      }
      this.loadData()
    },
    selectGiveBabyChange(value) {
      this.checkedGiveBabyList = value
    },
    // 保存赠送饰品配置 数据
    saveGiveBabyData() {
      Object.assign(this.checkedGiveBabyList, this.goodsValueModel)
      setOtherGoodsList(this.checkedGiveBabyList).then(res => {
        this.$message.success('保存成功')
        this.giveBabySetting.showHide = false
      })
    },
    giveBabyCloseDialog() {
      this.giveBabySetting.showHide = false
    },
    handleCloseDialog() {

    },
    // 赠送饰品配置
    giveBabySettingDialog() {
      getOtherGoodsList().then(res => {
        this.$log(res)
        this.goodsValueModel = res.data
      })
      this.giveBabySetting.showHide = true
    },
    // 算法概率
    mathSettingDialog() {
      this.getSettingData()
      this.mathSetting.showHide = true
    },
    // 获取算法概率配置
    getSettingData() {
      getLuckyProbabilityVO().then(res => {
        this.mathSettingModle = res.data
      })
    },
    // 保存算法概率配置
    saveWarningNum() {
      setLuckyProbabilityVO(this.mathSettingModle).then(res => {
        this.$log(res)
        this.handleFilter()
      })
      this.mathSetting.showHide = false
    },
    updateBabyDialog(row) {
      // this.getGoodsLuckyPlatformList()
      this.dialogStatus = 'update'
      this.addBaby.showHide = true
      this.typeName = row.typeName
      this.goodNameLook = row.goodsCnName
      this.addGoodModel.id = row.id
      this.addGoodModel.type = row.typeId
      this.addGoodModel.probabilityThreshold = row.probabilityThreshold
      this.addGoodModel.probabilityReal = row.probabilityReal
      this.goodsResultList = [{ lineId: row.id, lineName: this.goodNameLook }]
      this.selectChange(this.addGoodModel.id)
    },
    addBabyDialog() {
      this.getGoodsLuckyPlatformList()
      this.dialogStatus = 'create'
      this.typeName = ''
      this.typeList = []
      this.addGoodModel.id = undefined
      this.addGoodModel.type = undefined
      this.addGoodModel.probabilityThreshold = undefined
      this.addGoodModel.probabilityReal = undefined
      this.addBaby.showHide = true
    },
    settingDialog() {
      this.getSecondTypeListById(this.currParentId)
      this.setting.showHide = true
    },

    ruleGuideDialog() {
      this.ruleGuide.showHide = true
    },
    deleteBabyDialog() {
      const _vue = this
      if (_vue.multipleSelection.length < 1) {
        this.$message.error('请至少选择一条数据进行删除！')
        return
      }
      const selections = _vue.multipleSelection
      this.$confirm('确定删除选中的饰品么?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        var ids = []
        for (var i = 0; i < selections.length; i++) {
          ids.push(selections[i].id)
        }
        deleteGoodsFromLucky({ ids: ids }).then(res => {
          if (res.data.success) {
            this.$message.success('删除成功')
            this.loadData()
          } else {
            this.$message.error(res.data.msg)
          }
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消'
        })
      })
    },
    // 保存玩法管理
    guideSave() {
      setLuckyDescribe({ 'data': this.ruleGuideContent.content }).then(res => {
        this.$log(res)
        this.ruleGuide.showHide = false
      })
    },
    guideClose() {

    },
    // 加载玩法管理
    getGeneralDescribe() {
      getLuckyDescribe().then(res => {
        this.ruleGuideContent.content = res.data
      })
    }
  }
}
</script>
<style lang="scss" scoped>
$menuText:#14162E; // 侧边栏字体颜色
$hoverColor:#1D143C;// 鼠标停留主色调浅色
$mainColor:#3b425d;// 主色调
.app-container {
  padding: 30px;
}

.setting-contanier {
  padding: 50px;
  .box-container{
    padding: 20px;

  }

  .el-tag + .el-tag {
    margin-left: 10px;
  }
  .el-tag {
    color: $mainColor;
    background-color: #ffffff;
    border-color: $mainColor;
    ::v-deep .el-tag__close {
      color: $mainColor;
    }
    ::v-deep .el-icon-close:hover {
      color:#ffffff;
      background: $mainColor;
    }
  }
  .button-new-tag {
    margin-left: 10px;
    height: 32px;
    line-height: 30px;
    padding-top: 0;
    padding-bottom: 0;
    &:hover {
      color: #ffffff;
      background: $mainColor;
    }
  }
  .input-new-tag {
    width: 90px;
    margin-left: 10px;
    vertical-align: bottom;
  }
  ::v-deep .el-input__inner:focus {
    border-color: $mainColor;
  }
  .activity{
      background-color: $mainColor;
      color: #ffffff;
       ::v-deep .el-tag__close {
        color: #ffffff;
      }
    ::v-deep .el-icon-close:hover {
        color: $mainColor;
        background: #ffffff;
      }
  }
}
.table-btn{
  width: 80px;
  height: 35px;
  line-height:35px;
  padding: 0;
  background: #e7ecf8;
  border: 1px solid #3b425d;
  border-radius: 8px;
  font-size: 14px;
  color: #3b425d;
  &:hover{
    background: $mainColor;
    color: #fff;
  }
}
.addBaby-dialog{
  ::v-deep .el-dialog__body{
    margin: 100px 100px 50px 100px;
  }
}
.addBox-dialog{
  ::v-deep .el-dialog__body{
    width: 678px;
    text-align: center;
  }
  .give_div{
    margin: 0 auto;
    padding: 50px 0px;
    height: 400px;
  }
}
.filter-container {
  width: 100%;
  height: 48px;
  line-height: 48px;
  .filter-item {
    display: inline-block;
    vertical-align: middle;
    margin-bottom: 10px;
  }
  .kInput {
    position:absolute;
    right: 20px;
  }
  .filter-title {
    height: 48px;
    line-height: 48px;
    font-size: 16px;
    font-weight: 500;
    margin-right: 22px;
    color: #14162E;
  }
  .babyquality {
    margin-right: 20px;
  }
  .babylook,.babycategory ,.babytype {
    margin-right: 20px;
  }
}
.top-btn {
  margin: 30px 20px 30px 0px;
  font-size: 14px;
  color: #ffffff;
}
.upload-btn {
  font-size: 14px;
  color: #ffffff;
}
.kSelect .el-select .el-input .el-input__inner {
  width: 124px;
}

.top-radio-group{
  margin-bottom: 40px;
}

::v-deep .el-dialog__body{
    padding: 10px 30px;
}
::v-deep .el-radio-button__inner{
  &:hover{
    color: $mainColor;
  }
}
.giveBaby-dialog{
   ::v-deep .el-dialog__body{
    width: 678px;
    height: 500px;
  }
  .dialog-giveBabySetting{
    ::v-deep.el-input{
      width: 200px;
    }
    .price-input{
      width: 120px;
    }
  }
}

.top-right-btn-container{
  position: relative;
  .top-right-btn{
    position: absolute;
    right: 20px;
    top: 30px;
    background-color: #F8F7FB;
    border-color: transparent;
    color: #14162E;
    &:hover{
      color: #ffffff;
      background-color: $mainColor;
    }
    &:active{
      color: #14162E;
    }
  }
}
.editer {
  width: 500px;
  border-radius: 8px;
  float: left;
  box-sizing: border-box;
  color: #606266;
  ::v-deep .ql-container {
    height: 400px;
    border-radius: 0px 0px 8px 8px;
  }
  ::v-deep .ql-toolbar.ql-snow {
    border-radius: 8px 8px 0px 0px;
  }
}

.set_box {
    width: 600px;
    margin: 0 80px;
    box-sizing: border-box;
    .Recharge_Data {
      width: 100%;
      height: 40px;
      margin-top: 10px;
      display: flex;
      align-items: center;
      .Recharge_Data_box {
        width: 100%;
        height: 40px;
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        .el-input {
          width: 150px;
          height: 35px;
          input {
            width: 150px;
            height: 35px;
          }
        }
        span {
          font-size: 14px;
          width: 120px;
        }
      }
      .operation {
        width: 12%;
        display: flex;
        justify-content: space-between;
        .el-icon{
            &-circle-plus, &-remove{
              font-size: 22px;
              color:#3b425d;
              margin-left: 10px;
          }
        }
      }
     }
 }
</style>
